Demo: Transforming Inputs (Self-Paced)
Transforming inputs can sometimes improve the fit of a model to the data. Recall that in our data set we have several gift-related variables that are heavily skewed. In this demonstration, you learn to transform such variables using a pre-created flow to regularize their distribution. For brevity, we will consider just one of the gift-related variables in this demonstration.
Reminder: If you restarted your SAS session, or it has timed out due to inactivity, you must re-create the course libraries,
LOCALLIB and
VST. To do this, run the
AssignLibrary flow.
- In SAS Viya, launch SAS Studio by clicking the Applications menu button (the three-by-three grid in the upper left corner), expand ANALYTICS LIFE CYCLE, and click Develop Code and Flows.
- In the navigation panel on the far left, click the Explorer button (second from top). Expand Files >Home > workshop > VST. Double-click AssignLibrary.flw to open it.
- Click the Run button on the flow toolbar.
Demo Steps
- Open the previously created flow Data Preprocessing.flw from the VST folder.
- Click on the Steps icon on the left side of the Navigation Pane. Under SAS Steps, expand Prepare Data, then double click on the Transform columns step.
- Next, move your mouse towards the edge of the IMPUTED_PVA node until the pointer becomes a hand icon. Click and drag an arrow from IMPUTED_PVA node to the box on the left side of the Transform Columns node (the input port). Now Transform Columns is connected to the IMPUTED_PVA data.
- Add another Table step to the flow by double clicking Table under Data (Input and Output). For this node, under Table Properties, enter VST for Library and PVA_DONORS_FINAL in the Table name field.
- In the work area, connect the output port of the Transform Columns node to the PVA_FINAL_DONORS node. Click the Arrange nodes button to visually organize the flow.
- Click on the Transform Columns node. Under the Data tab, Find Select a server for this step and choose the CAS radio button.
- Scroll down to the Variable 1 field under Transform 1. Click the plus sign (+) and choose GiftCnt36. Click OK to close the Column Selection window.
- In the Transform field under GiftCnt36, use the drop-down arrow to choose Specify custom transformation. In the Custom transformation field, type in log(GiftCnt36+1).

Note the +1 added to the variable GiftCnt36. Some donors did not donate in the past 36 months, so have a GiftCnt36 value of zero. The log of zero is undefined, so adding 1 to GiftCnt36 prevents the transformation from generating missing values when GiftCnt36=0.
- Click on the Output tab. Make sure Replace existing output table is selected. Under Specify the data to show in the Results tab, use the dropdown menu to select Specific number of observations. Leave the default number of observations set to 10.
- Run the flow and save Data Preprocessing.flw. View the Results.
Partial view of PVA_DONORS_FINAL:

The Results tab in the work area shows the first ten rows of PVA_FINAL_DONORS. Note that you may see a different 10 rows on your computer. You can see that a new input named tr1_GiftCnt36 has been added to the table.
Going forward you might want to use this log transformed variable over the original variable.